package id.net.iconpln.bb.client.tools;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;

public class FusionMapWidget extends Composite {

	  public final static int TYPE_CYLINDER = 1;		  
	  public final static int TYPE_BAR = 2;
	  private static int seqId = 1;
	  private HTML holder = null;
	  private String divId = null;;
	  private int chartType = TYPE_CYLINDER;
	  private int width = 0;
	  private int height = 0;
	  private String swf = null;
	  private String dataUrl = null;
	  private String dataXml = null;
	  private boolean transparent = true;

	  public FusionMapWidget( String swf, int chartType, int width, int height ) {

	    this.chartType = chartType;
	    this.width = width;
	    this.height = height;
	    this.swf = swf;		    
	    divId = "map" + (seqId++);
	    holder = new HTML("<div id=\""+divId+"\"></div>");		    
	    initWidget(holder);
	  }
	  
	  public void setDataUrl( String dataUrl ) {
	    this.dataUrl = dataUrl;
	  }
	  public void setDataXml( String dataXml ) {
		    this.dataXml = dataXml;
		  }
	  public void setTransparent( boolean transparent ) {
		    this.transparent = transparent;
	  }		    
	  protected void initWidget( Widget widget ) {
	    super.initWidget( widget );
	  }



	  protected void onAttach( ) {
	    FusionMaps map = null;
	    switch ( chartType ) {
	      case TYPE_CYLINDER:
	        map = FusionMaps.getMap(swf ,Integer.toString( width ), Integer.toString( height ) );
	      break;
	      case TYPE_BAR:
		        map = FusionMaps.getMap(swf ,Integer.toString( width ), Integer.toString( height ) );
		  break;
	    }
	    
//	    map.setDataUrl( dataUrl );
	    map.setTransparent(transparent);
	    map.setDataXml(dataXml);
	    map.render( divId );

	  }

}
